package com.cc.service.impl;

import com.cc.comm.Page;
import com.cc.entity.Book;
import com.cc.mapper.BookMapper;
import com.cc.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author Administrator
* @description 针对表【book】的数据库操作Service实现
* @createDate 2025-09-01 14:46:10
*/
@Service
public class BookServiceImpl implements BookService{
    @Autowired
    BookMapper bookMapper;

    @Override
    public Page<Book> getBookPage(String bookName, String author, Integer pageNum, Integer pageSize) {
        Page<Book> page = new Page<>();
        page.setPageNum(pageNum);
        page.setPageSize(pageSize);
        //获取总条数
        Integer totalCount = bookMapper.getBookListTotalCount(bookName,author);
        page.setTotalCount(totalCount);
        page.setData(bookMapper.getBookListPage(bookName,author,(pageNum-1)+pageSize,pageSize));
        return page;
    }
}
